<?php
require_once '../../../include/cp_header.php' ;
require_once XOOPS_ROOT_PATH . '/modules/x-info/class/x-info.class.php';

$xinfo = new xinfo;

// $pi_dv = array("apache", "apache2handler", "com", "mbstring", "mysql", "odbc", "session", "standard", "zlib");

xoops_cp_header();
include('./mymenu.php') ;

switch ($_GET['op']) {
    case 'xoops_info':
        $xoops_info = $xinfo->xoopsinfo();
        echo '<table width="95%" class="outer" cellpadding="4" cellspacing="1">' . "\n";
        echo '<tr class="head"><td>' . _AM_CONST_NAME . '</td><td>' . _AM_CONST_VALUE . '</td><td>' . _AM_CONST_DESC . '</td></tr>' . "\n";
        $i = 0;
        foreach($xoops_info as $key => $const) {
            $class = ($i % 2 == 0) ? "even" : "odd";
            echo '<tr class="' . $class . '"><td>' . $const['name'] . '</td><td>' . $const['value'] . '</td><td>' . $const['desc'] . '</td></tr>' . "\n";
        } 
        echo '</table>';
        echo '<hr><a target="_blank" href="http://www.riaf.org/">x-info / riaf web</a>';
        break;

    case 'php_info':
        $php_info = $xinfo->phpinfo();
        foreach($php_info as $cat => $val) {
            // $flag = (in_array($cat, $pi_dv)) ? 1 : 0;
            echo '<table width="95%" class="outer" cellpadding="4" cellspacing="1">' . "\n";
            $content = "";
            $i = 0;
            $cols_flag = 0;
            foreach($val as $title => $array) {
                $count = count($array); 
                // if ($count == 2 && $flag == 1) {
                if ($count == 2) {
                    $class = ($i % 2 == 0) ? "even" : "odd";
                    if ($cols_flag == 0) {
                        $content .= '<tr class="head"><td></td><td>Local Value</td><td>Master Value</td></tr>';
                        $cols_flag = 1;
                    } 
                    $content .= '<tr class="' . $class . '"><td><b>' . $title . '</b></td><td>' . $array[0] . '</td><td>' . $array[1] . '</td></tr>' . "\n";
                    $i++;
                } else {
                    foreach($array as $value) {
                        $class = ($i % 2 == 0) ? "even" : "odd"; 
                        // $cols = ($flag == 1) ? ' colspan="2"' : "";
                        $cols = ' colspan="2"';
                        $content .= '<tr class="' . $class . '"><td><b>' . $title . '</b></td><td' . $cols . '>' . $value . '</td></tr>' . "\n";
                        $i++;
                    } 
                } 
            } 
            // $cols = ($flag == 1) ? 3 : 2;
            $cols = 3;
            echo '<tr class="head"><td colspan="' . $cols . '" align="center">' . $cat . '</td></tr>' . "\n";
            echo $content;
            echo '</table><br />';
        } 
        echo '<hr><a target="_blank" href="http://www.riaf.org/">x-info / riaf web</a>';
        break;

    case 'security_check':
        $sec_item = $xinfo->xoops_security_check();
        echo '<table width="95%" class="outer" cellpadding="4" cellspacing="1">' . "\n";
        $i = 0;
        foreach($sec_item as $item) {
            $class = ($i % 2 == 0) ? "even" : "odd";
            echo '<tr class="' . $class . '">';
            echo '<td>' . $item['name'] . '</td>';
            echo '<td>' . $item['key'] . '</td>';
            echo '<td>' . $item['value'] . '</td>';
            $safe = ($item['check'] == true) ? _AM_SECURE : _AM_NOTSECURE ;
            echo '<td>' . $safe . '</td>';
            echo '</tr>' . "\n";
            $i++;
        } 
        echo '</table>' . "\n";
        echo '<hr><a target="_blank" href="http://www.riaf.org/">x-info / riaf web</a>';
        break;
    default:
        echo '<table width="95%" class="outer" cellpadding="4" cellspacing="1"><tr class="even"><td>
<h3>' . _AM_XINFO_NAME . '</h3>
<ul>
 <li><a href="index.php?op=xoops_info">' . _AM_XOOPSINFO . '</a>
 <li><a href="index.php?op=php_info">' . _AM_PHPINFO . '</a>
 <li><a href="index.php?op=security_check">' . _AM_SECURITYCHECK . '</a>
</ul>
</td></tr></table>
<a target="_blank" href="http://www.riaf.org/">x-info / riaf web</a>
';
} 

xoops_cp_footer();

?>